#include<iostream>
using namespace std;
int main()
{
	int n, m;
	cin >> n >> m;
	int p[n+1];
	int px;
	for (int i = 0; i < n+1; i++)
	{
		cin >> p[i];
	}
	px = p[n];
	for (int i = n-1; i >= 0; i--)
	{
		px = p[i]+px*m;
	}
	cout << px << endl;
} 
